<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="/template.xhtml">
        <ui:define name="title">
            <h:outputText value="#{bundle.editPersonTitle}"></h:outputText>
        </ui:define>
        <ui:define name="content">
            <h:panelGroup id="messagePanel" layout="block">
                <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
            </h:panelGroup>
            <h:form>
                <h:panelGrid columns="2">
                    <h:outputLabel value="#{bundle.firstName}:" for="firstName" />
                    <h:inputText id="firstName" value="#{personController.selected.firstName}" title="#{bundle.firstName}" required="true" requiredMessage="#{bundle.OBLIG}"/>
                    <h:outputLabel value="#{bundle.lastName}:" for="lastName" />
                    <h:inputText id="lastName" value="#{personController.selected.lastName}" title="#{bundle.lastName}" required="true" requiredMessage="#{bundle.OBLIG}"/>
                    <h:outputLabel value="#{bundle.phoneNumber}:" for="phoneNumber" />
                    <h:inputText id="phoneNumber" value="#{personController.selected.phoneNumber}" title="#{bundle.phoneNumber}" required="true" requiredMessage="#{bundle.OBLIG}"/>
                    <h:outputLabel value="#{bundle.emailAddress}:" for="emailAddress" />
                    <h:inputText id="emailAddress" value="#{personController.selected.emailAddress}" title="#{bundle.emailAddress}" required="true" requiredMessage="#{bundle.OBLIG}"/>
                    <h:outputText value="#{bundle.username}:"/>
                    <h:outputText id="username" value="#{personController.selected.users.username}" title="#{bundle.username}" />
                    <h:outputLabel value="#{bundle.password}:" for="password"/>
                    <h:inputSecret id="password" value="#{personController.selected.users.password}" title="#{bundle.password}" required="false"/>
                    <h:outputLabel value="#{bundle.repeatPassword}:" for="password2"/>
                    <h:inputSecret id="password2" title="#{bundle.repeatPassword}" required="false" validator="passwordEqualsValidator"/>
                    <h:outputText value="#{bundle.teacher}:"/>
                    <h:selectBooleanCheckbox value="#{personController.selected.users.teacher}" title="#{bundle.teacher}"/>
                    <h:outputText value="#{bundle.instAdmin}:"/>
                    <h:selectBooleanCheckbox value="#{personController.selected.users.instAdmin}" title="#{bundle.instAdmin}"/>
                    <h:outputText value="#{bundle.sysAdmin}:"/>
                    <h:selectBooleanCheckbox value="#{personController.selected.users.sysAdmin}" title="#{bundle.sysAdmin}"/>
                    <h:outputText value="#{bundle.worksAtInstitution}:" />
                    <h:selectManyListbox value="#{personController.institutionCollection}" title ="#{bundle.worksAtInstitution}?" required="true" requiredMessage="#{bundle.OBLIG}">
                       	<f:selectItems value="#{institutionController.itemsAvailableSelectMany}"/>
                        <f:converter converterId="instituteConverter" />
                    </h:selectManyListbox>

                </h:panelGrid>
                <h:commandLink action="#{personController.update}" value="#{bundle.SAVE}"/>
                <br />
                <br />
                <h:commandLink action="#{personController.destroy}" value="#{bundle.DESTROY}"/>
                <br />
                <br />
                <h:commandLink action="View" value="#{bundle.VIEW}" immediate="true"/>
                <br />
                <br />
                <h:commandLink action="#{personController.prepareList}" value="#{bundle.SHOW_ALL}" immediate="true"/>
            </h:form>
        </ui:define>
    </ui:composition>

</html>
